package com.farsight.leo.fssmartlock.db;

import java.util.List;

import androidx.room.Dao;
import androidx.room.Delete;
import androidx.room.Insert;
import androidx.room.OnConflictStrategy;
import androidx.room.Query;
import androidx.room.Update;

/**
 * Author: Administrator
 * Date: 2019/9/17
 * Project: SmartLockApp
 * Description:
 */
@Dao
public interface AuthCodeDao {
    @Insert(onConflict = OnConflictStrategy.REPLACE)
    void insert(AuthCodeEntity entity);

    @Delete()
    void delete(AuthCodeEntity entity);

    @Update(onConflict = OnConflictStrategy.REPLACE)
    void update(AuthCodeEntity entity);

    @Query("SELECT * FROM tbl_auth_code WHERE user_id=:userId AND device_id=:deviceId ORDER BY valid_date DESC")
    List<AuthCodeEntity> query(int userId, int deviceId);

}
